package h0907;

/**
 * @author 不知名帅哥
 * @version 1.0
 * @description 跳跃游戏
 * @date 2024/9/7 21:54
 */
public class JumpGame {
    public static void main(String[] args) {

    }

    public boolean canJump(int[] nums) {
        int maxReach = 0;
        int n = nums.length;
        for (int i = 0; i < n; i++) {
            if (i > maxReach) {
                return false;
            }
            maxReach = Math.max(maxReach, i + nums[i]);
        }
        return maxReach >= n-1;
    }
}
